<template>
  <div>
    <header>
      <div class="top">
        <span @click="$router.go(-1)"><van-icon name="arrow-left" /></span
        ><span>讲师详情</span><span></span>
      </div>
      <div class="box">
        <img :src="teList.avatar" alt="" />
        <span>女 10年教龄</span>
        <button @click="add">{{ flag == 1 ? "取消关注" : "关注" }}</button>
      </div>
    </header>
    <div class="tab">
      <van-tabs v-model="active">
        <van-tab title="讲师介绍">讲师介绍</van-tab>
        <van-tab title="主讲课程">主讲课程</van-tab>
        <van-tab title="学员评价">
          <img
            src="http://xl.9yuecloud.com/assets/img/empty.0d284c2e.png"
            alt=""
          />
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>

<script>
import { NavBar, Icon, Tab, Tabs } from "vant";
import { teacherId,guan,coursebasis } from "../request/http";
export default {
  name: "teacherDetail",
  data() {
    return {
      teList: [],
      flag: "",
    };
  },
  methods: {
    add() {
      // console.log(11);
      guan(this.id).then((res) => {
        console.log(res);
        this.flag = res.flag;
      });
      coursebasis(this.id).then((res) => {
        console.log(res);
        this.info = res.teacher;
      });
    },
  },
  mounted() {
    teacherId(this.$route.query.id).then((res) => {
      console.log(res);
      this.teList = res.teacher;
      this.flag = res.flag
    });
  },
  components: {
    [NavBar.name]: NavBar,
    [Icon.name]: Icon,
    [Tab.name]: Tab,
    [Tabs.name]: Tabs,
  },
};
</script>

<style lang="scss" scoped>
header {
  position: relative;
  width: 100%;
  height: 100px;
  background-color: #5ba2f4;
  .top {
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.625rem;
    box-sizing: border-box;
    padding: 20px;
  }
  .box {
    position: absolute;
    left: 20px;
    bottom: -70px;
    right: 20px;
    background-color: #fff;
    height: 100px;
    border-radius: 15px;
    img {
      width: 60px;
      height: 60px;
    }
    button {
      width: 80px;
      height: 30px;
      line-height: 0.3333rem;
      border-radius: 30px;
      color: #eb6100;
    }
  }
}
.tab {
  width: 100%;
  margin: 100px 0;
  text-align: center;

  img {
    width: 100%;
    height: 780px;
    background-color: #fff;
  }
}
</style>